from sqlmodel import SQLModel, Field, Index
from datetime import datetime

class WpUser(SQLModel, table=True):
    """Waveup用户表数据库模型"""
    __tablename__ = "t_wp_user"  # 对应数据库表名

    # 索引定义（优化查询性能）
    __table_args__ = (
        Index("idx_uid", "uid", unique=True, info="用户ID唯一索引"),
        Index("idx_userOpenId", "userOpenId", unique=True, info="用户OpenID唯一索引"),
    )

    # 字段定义
    id: int = Field(default=None, primary_key=True, index=True, description="主键ID")
    uid: int = Field(default=0, description="用户ID")
    userOpenId: str = Field(default="", index=True, max_length=64, description="Waveup用户OpenID")
    mobileNo: str = Field(default="", max_length=32, description="用户手机号")
    email: str = Field(default="", max_length=64, description="用户邮箱")
    nickName: str = Field(default="", max_length=64, description="用户昵称")
    avatar: str = Field(default="", max_length=256, description="用户头像URL")
    kycStatus: int = Field(default=0, description="实名认证状态 0、未认证 1、已认证")
    createdAt: datetime = Field(default_factory=datetime.now, description="创建时间")
    updatedAt: datetime = Field(default_factory=datetime.now, description="更新时间")